home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / program / vol16n09.zip / MFCTIP.ZIP / PGCNT.TXT < prev   
Text File  |  1997-04-14  |  916b  |  31 lines

  1. BOOL CAccelView::OnPreparePrinting (CPrintInfo* pInfo)
  2. {
  3.     //
  4.     // Compute the page count.
  5.     //
  6.     if (!pInfo->m_bPreview) {
  7.         CPrintInfo pi;
  8.         if (AfxGetApp ()->GetPrinterDeviceDefaults (&pi.m_pPD->m_pd)) {
  9.             HDC hDC = pi.m_pPD->m_pd.hDC;
  10.             if (hDC == NULL)
  11.                 hDC = pi.m_pPD->CreatePrinterDC ();
  12.             if (hDC != NULL) {
  13.                 CDC dc;
  14.                 dc.Attach (hDC);
  15.                 int nWidth = dc.GetDeviceCaps (HORZRES);  // Page width
  16.                 int nHeight = dc.GetDeviceCaps (VERTRES); // Page height
  17.  
  18.                 // TODO: Compute nPageCount from nWidth and nHeight
  19.  
  20.                 pInfo->SetMaxPage (nPageCount);
  21.                 ::DeleteDC (dc.Detach ());
  22.             }
  23.         }
  24.     }
  25.  
  26.     //
  27.     // Display the Print dialog and create a printer DC.
  28.     //
  29.     return DoPreparePrinting (pInfo);
  30. }
  31.